package com.asset.salesforce.dao;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.asset.salesforce.domain.InvoiceService;
import com.asset.salesforce.domain.InvoiceSku;
import com.asset.salesforce.domain.Sales;
import com.asset.salesforce.service.InvoiceOperationService;

import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;


public class SalesDAO {

	@Autowired
	private InvoiceOperationService invoiceOperationService;
	/**
	 * Our dummy datasource. Retrieves a collection of data that is wrapped by a JRBeanCollectionDataSource.
	 *  
	 * @return a JRBeanCollectionDataSource collection
	 */
	public  JRDataSource getDataSource() {
		// Create an array list of Sales 
		List<Sales> items = new ArrayList<Sales>();
//		List<InvoiceSku> invoiceSkus = invoiceOperationService.getInvoiceSkusByInvoice(id);
//		List<InvoiceService> invoiceServices = invoiceOperationService.getInvoiceServicesByInvoice(id);
		// We'll add three Sales items
		// You can populate data from a custom JDBC or DAO layer
		// For this demo, we'll create an in-memory list of items
		
		// Create first item
		Sales item1 = new Sales();
		item1.setDate("1/1/2013");
		item1.setCompanyName("asset");
		item1.setTelFax("01215848848");
		item1.setAddress("abas al3ad");
		item1.setWebsite("wddw.com");
		item1.setContactName("fgfgf");
		item1.setContactTel("2343242423");
		//item1.setContactAddrss("adqwdqdwe");
		item1.setContactEmail("hishamelkadraway@gmail.com");
		item1.setProductName("grtt");
		item1.setProductCode("21");
		item1.setProductDiscount("22%");
		item1.setProductPrice("23");
		item1.setProductQuantity("21");
		item1.setProductTax1("21");
		item1.setProductTax2("221");
		item1.setProductLineTotal("213");
		item1.setServicetName("213");
		item1.setServiceInfo("ewdww");
		item1.setServiceDiscount("32%");
		item1.setServiceCost("213");
		item1.setServiceHours("34");
		item1.setServiceTax1("32");
		item1.setServiceTax2("54");
		item1.setServiceLineTotal("554");
		item1.setInvoiceTotal("54887");
		item1.setTotalDiscount("555");
		item1.setBalance("23");
		// Add to list
		Sales item2 = new Sales();
		item2.setProductName("grtt");
		item2.setProductCode("21");
		item2.setProductDiscount("22%");
		item2.setProductPrice("23");
		item2.setProductQuantity("21");
		item2.setProductTax1("21");
		item2.setProductTax2("221");
		item2.setProductLineTotal("213");
		items.add(item1);
		items.add(item2);

		// Wrap the collection in a JRBeanCollectionDataSource
		// This is one of the collections that Jasper understands
		JRDataSource ds = new JRBeanCollectionDataSource(items);	
		
		// Return the wrapped collection
		return ds;
	}
}
